from config import *

class HomePage:
    def GET(self):
		return render.HomePage()
	
class Product:
    def GET(self):
		return render.product()

class ItemForm:
	def GET(self):
		input = web.input()
		page = int(input.page)
		result = ''
		for i in range(10):
			result += str(render.ItemForm((page - 1) * 10 + i))
		return result

class PostedItem:
	def GET(self):
		input = web.input()
		page = int(input.page)
		result = ''
		for i in range(10):
			result += str(render.PostedItem((page - 1) * 10 + i))
		return result

class SoldItem:
	def GET(self):
		input = web.input()
		page = int(input.page)
		result = ''
		for i in range(10):
			result += str(render.SoldItem((page - 1) * 10 + i))
		return result
		
class Posted:
	def GET(self): 
		return render.posted()
		
class Sold:
	def GET(self): 
		return render.sold()

class Personal:
	def GET(self): 
		#if web.ctx.session.IsLogined == 0:
			#return 'isn\'t login'
		return render.personal()	
	def POST(self):
		if web.ctx.session.IsLogined == 0:
			return 'isn\'t login'
		input = web.input()
		idregister = web.ctx.session.userID
		#result = db.select(TableRegister, myvar, "idregister = $idergister")
		#row = result[0]
		#update_data = dict(grade='12')
		db.update(TableUserInfo, where = "idregister = %s" % idregister, qq = input.qq, email = input.email, \
			phone = input.phone, shortphone = input.shortphone, password = input.password, \
			realname = input.realname, grade = input.grade)
		print '*' * 90
		print 'personal post'